<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
 <head>

  <script type="text/javascript" src="sclmenu.js"></script>
  <script type="text/javascript" src="js/prototype/prototype.js"></script>
  <script type="text/javascript" src="js/bramus/jsProgressBarHandler.js"></script>
  <link rel="stylesheet" type="text/css" href="cssource.css" >

  <title>Arcata Waste Water Marsh Modeling Project</title>
  <?php
   if($_POST){
/*    $pg=$_POST['pg'];
    $NAME=array("inflow","precip","pval","pname","month","year","day","Page2Select","P2Name","P2id","rnam","pnam","P2Pic","pump1");
//    $routes=array("Ox1_Ox2_West","Ox1_Ox2_East","Ox2_TM1_1","Ox2_TM1_2","Ox2_TM2_1","Ox2_TM2_2","Ox2_Ox3_North","Ox2_Ox3_South","Ox2_Ox2Box","Ox2Box_TM4","Ox3_TM3","Ox3_Chl_1","Ox3_Chl_2","Ox3_Chl_3","TM1_TBox","TBox_Chl","TM2_TBox_MSouth","TM2_TBox_South","TM2_TBox_North","TM2_TBox_MNorth","TM3_TBox_MWest","TM3_TBox_West","TM3_TBox_East","TM3_TBox_MEast","TM4_TM1","Chl_Allen","Allen_Gearheart_1","Allen_Gearheart_2","Allen_Gearheart_3","Gearheart_Hauser_Small","Gearheart_Hauser_Big","Hauser_Brackish","Hauser_Chl","Chl_Bay");
    $routes=array("Ox2_TM1_1","Ox2_TM1_2","Ox2_TM2_1","Ox2_TM2_2","Ox2_Ox3_North","Ox2_Ox3_South","Ox3_TM3","TBox_Chl","Chl_Allen","Hauser_Brackish","Hauser_Chl","Chl_Bay");
    $ponds=array("Ox1","Ox2","Ox2_Box","Ox3","TM1","TM2","TM3","TM4","T_Box","Chlorine","Allen","Gearheart","Hauser","Brackish","Bay");
    $pumps=array("Ox3_Chl_1","Ox3_Chl_2","Ox3_Chl_3");

    $rerun=array("inflow","precip","year","month","day");
    $pumpDescriptor=array(
    "Ox1_Ox2_West"          =>"Ox2 to Ox3 (West)",
    "Ox1_Ox2_East"          =>"Ox2 to Ox3 (East)",
    "Ox2_TM1_1"             =>"Ox2 to TM1 (1)",
   "Ox2_TM1_2"             =>"Ox2 to TM1 (2)",
    "Ox2_TM2_1"             =>"Ox2 to TM2 (1)",
    "Ox2_TM2_2"             =>"Ox2 to TM2 (2)",
    "Ox2_Ox3_North"         =>"Ox2 to Ox3 (North)",
    "Ox2_Ox3_South"         =>"Ox2 to Ox3 (South)",
    "Ox2_Ox2Box"            =>"Ox2 to Stilling Tower",
    "Ox2Box_TM4"            =>"Stilling Tower to TM4",
    "Ox3_TM3"               =>"Ox3 to TM3",
    "Ox3_Chl_1"             =>"Ox3 to Ox3 Well",
    "Ox3_Chl_2"             =>"Ox3 Well to Chlorine Contact",
    "Ox3_Chl_3"             =>"Ox2 to Chlorine Contact",
    "TM1_TBox"              =>"TM1 to TBox",
    "TBox_Chl"              =>"TBox to Chlorine Contact Basin",
    "TM2_TBox_MSouth"       =>"TM2 to TBox (Most South)",
    "TM2_TBox_South"        =>"TM2 to TBox (South)",
    "TM2_TBox_North"        =>"TM2 to TBox (North)",
    "TM2_TBox_MNorth"       =>"TM2 to TBox (Most North)",
    "TM3_TBox_MWest"        =>"TM3 to TBox (Most West)",
    "TM3_TBox_West"         =>"TM3 to TBox (West)",
    "TM3_TBox_East"         =>"TM3 to TBox (East)",
    "TM3_TBox_MEast"        =>"TM3 to TBox (Most East)",
    "TM4_TM1"               =>"TM4 to TM1",
    "Chl_Allen"             =>"Chlorine Contact to Allen",
    "Allen_Gearheart_1"     =>"Allen to Gearheart (1)",
    "Allen_Gearheart_2"     =>"Allen to Gearheart (2)",
    "Allen_Gearheart_3"     =>"Allen to Gearheart (3)",
    "Gearheart_Hauser_Small"=>"Gearheart to Hauser (Small)",
    "Gearheart_Hauser_Big"  =>"Gearheart to Hauser (Big)",
    "Hauser_Brackish"       =>"Hauser to Brackish",
    "Hauser_Chl"            =>"Hauser to Chlorine Contact Basin",
    "Chl_Bay"               =>"Chlorine Contact Basin to Bay"      );

    $c=0;
    foreach ($routes as $val){
     $_POST[$val]=array('Current_Value','Num_Values','List');
     $_POST[$val]['Is_Pump']=$_POST[''.$val.'_Is_Pump'];
     if(!$_POST[$val]['Is_Pump']){
     $_POST[$val]['Weir_Height']=$_POST[''.$val.'_Weir_Height'];
     $_POST[$val]['Is_Adjustable']=$_POST[''.$val.'_Is_Adjustable'];
     $_POST[$val]['Box_Top']=$_POST[''.$val.'_Box_Top'];
     $_POST[$val]['Difference']=$_POST[''.$val.'_Difference'];
     }
     else{
     $_POST[$val]['List']=array();
     $_POST[$val]['Current_Value']=$_POST[''.$val.'_Current_Value'];
     $_POST[$val]['Num_Values']=$_POST[''.$val.'_Num_Values'];
     $_POST[$val]['Hours']=$_POST[''.$val.'_Hours'];
     $_POST[$val]['Offset']=$_POST[''.$val.'_Offset'];
     $c=0;
     while ($c<$_POST[$val]['Num_Values']){
      $_POST[$val]['List'][]=$_POST[''.$val.'_List_'.$c];
      $c++;
     }
     }
    }
    $c=0;
    while($c<5){
     $_POST["I".$c]=array("inflow","precip","year","month","day");
     $_POST["I".$c]["inflow"]=$_POST["I".$c."_inflow"];
     $_POST["I".$c]["precip"]=$_POST["I".$c."_precip"];
     $_POST["I".$c]["year"]=$_POST["I".$c."_year"];
     $_POST["I".$c]["month"]=$_POST["I".$c."_month"];
     $_POST["I".$c]["day"]=$_POST["I".$c."_day"];
     $c++;
    }
    $months=array("January","February","March","April","May","June","July","August","September","October","November","December");
   }
   else {
    $rerun=array("inflow","precip","year","month","day");
    $_POST["I0"]=array("inflow","precip","year","month","day");
    $_POST["I1"]=array("inflow","precip","year","month","day");
    $_POST["I2"]=array("inflow","precip","year","month","day");
    $_POST["I3"]=array("inflow","precip","year","month","day");
    $_POST["I4"]=array("inflow","precip","year","month","day");

    $ponds=array("Ox1","Ox2","Ox2_Box","Ox3","TM1","TM2","TM3","TM4","T_Box","Chlorine","Allen","Gearheart","Hauser","Brackish","Bay");
    $description=array("P1W1"=>"Ox Pond 1 to Ox Pond 2","P1W2"=>"Ox Pond 1 to Ox Pond 2","P2W1"=>"Ox Pond 2 to TM1","P2W2"=>"Ox Pond 2 to TM1","P2W3"=>"Ox Pond 2 to TM2","P2W4"=>"Ox Pond 2 to TM2","P2W5"=>"Ox Pond 2 to TM3","P2W6"=>"Ox Pond 2 to TM3");
    
    $_POST['modelRunning']=0;
    $pg=1;
    $f=fopen('../pondSim/input/pond.surf','r');
    $c=0;
    while($info=fscanf($f,"%f %s %s\n")){
     $_POST[$ponds[$c]]=$info[0];
     $c++;
    }
    fclose($f);

    $f=fopen("../inflow/inflow","r");
    $t=0;
    $ptr=-3;
    while ($t<5) {
     fseek($f,$ptr,SEEK_END);
     if(fgetc($f)=="\n")
      $t++;
     $ptr--;
    }

    $info=fscanf($f,"%s %s %s %s %s %s\n");
    $_POST["I0"]["year"]=$info[0];
    $_POST["I0"]["month"]=$info[1];
    $_POST["I0"]["day"]=sprintf('%02s',$info[2]);
    $_POST["I0"]["inflow"]=sprintf('%1.2f',round(1000*(float)$info[5])/1000);

    $info=fscanf($f,"%s %s %s %s %s %s\n");
    $_POST["I1"]["year"]=$info[0];
    $_POST["I1"]["month"]=$info[1];
    $_POST["I1"]["day"]=sprintf('%02s',$info[2]);
    $_POST["I1"]["inflow"]=sprintf('%1.2f',round(1000*(float)$info[5])/1000);
    $ival=$_POST["I2"]["inflow"];

    $info=fscanf($f,"%s %s %s %s %s %s\n");
    $_POST["I2"]["year"]=$info[0];
    $_POST["I2"]["month"]=$info[1];
    $_POST["I2"]["day"]=sprintf('%02s',$info[2]);
    $_POST["I2"]["inflow"]=sprintf('%1.2f',round(1000*(float)$info[5])/1000);
    
    $info=fscanf($f,"%s %s %s %s %s %s\n");
    $_POST["I3"]["year"]=$info[0];
    $_POST["I3"]["month"]=$info[1];
    $_POST["I3"]["day"]=sprintf('%02s',$info[2]);
    $_POST["I3"]["inflow"]=sprintf('%1.2f',round(1000*(float)$info[4])/1000);

    $info=fscanf($f,"%s %s %s %s %s %s\n");
    $_POST["I4"]["year"]=$info[0];
    $_POST["I4"]["month"]=$info[1];
    $_POST["I4"]["day"]=sprintf('%02s',$info[2]);
    $_POST["I4"]["inflow"]=sprintf('%1.2f',round(1000*(float)$info[3])/1000);
    $ival=$_POST["I1"]["inflow"];

    fclose($f);
    $f=fopen("../inflow/rainfall","r");
    $t=0;
    $ptr=-3;
    while ($t<5){
     fseek($f,$ptr,SEEK_END);
     if(fgetc($f)=="\n")
      $t++;
     $ptr--;
    }

    $info=fscanf($f,"%s %s %s %s %s %s %s\n");
    $_POST["I0"]["precip"]=sprintf('%1.2f',round(1000*(float)$info[6])/1000);
    $info=fscanf($f,"%s %s %s %s %s %s %s\n");
    $_POST["I1"]["precip"]=sprintf('%1.2f',round(1000*(float)$info[6])/1000);
    $info=fscanf($f,"%s %s %s %s %s %s %s\n");
    $_POST["I2"]["precip"]=sprintf('%1.2f',round(1000*(float)$info[5])/1000);
    $info=fscanf($f,"%s %s %s %s %s %s %s\n");
    $_POST["I3"]["precip"]=sprintf('%1.2f',round(1000*(float)$info[4])/1000);
    $info=fscanf($f,"%s %s %s %s %s %s %s\n");
    $_POST["I4"]["precip"]=sprintf('%1.2f',round(1000*(float)$info[3])/1000);

    $pval=$_POST["I1"]["precip"];
    fclose($f);

//    $routes=array("Ox1_Ox2_West","Ox1_Ox2_East","Ox2_TM1_1","Ox2_TM1_2","Ox2_TM2_1","Ox2_TM2_2","Ox2_Ox3_North","Ox2_Ox3_South","Ox2_Ox2Box","Ox2Box_TM4","Ox3_TM3","Ox3_Chl_1","Ox3_Chl_2","Ox3_Chl_3","TM1_TBox","TBox_Chl","TM2_TBox_MSouth","TM2_TBox_South","TM2_TBox_North","TM2_TBox_MNorth","TM3_TBox_MWest","TM3_TBox_West","TM3_TBox_East","TM3_TBox_MEast","TM4_TM1","Chl_Allen","Allen_Gearheart_1","Allen_Gearheart_2","Allen_Gearheart_3","Gearheart_Hauser_Small","Gearheart_Hauser_Big","Hauser_Brackish","Hauser_Chl","Chl_Bay");
    $routes=array("Ox2_TM1_1","Ox2_TM1_2","Ox2_TM2_1","Ox2_TM2_2","Ox3_TM3","TBox_Chl","Chl_Allen","Hauser_Brackish","Hauser_Chl","Chl_Bay");
    $pumps=array("Ox3_Chl_1","Ox3_Chl_2","Ox3_Chl_3");


    $f=fopen('../pondSim/params/con.crest','r');$c=0;
    $g=fopen('../pondSim/params/con.top','r');
    while($info=fscanf($f,"%f\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s") && $info1=fscanf($g,"%f %s %s %s %s %s %s %s %s")){
/*     $k=1;$pump=false;
     while($k<10){
      if (strcmp("(PUMP)",$info[$k])==0) $pump=true;
      $k++;
     }
     if ($pump){
      $_POST[$routes[$c]]=array("Current_Value","Num_Values","List","Is_Pump","Hours","Offset");
      echo $pump;
     }
     else*/
/*     if ($info[2]!="#"){
      $_POST[$info[2]]=array("Weir_Height","Box_Top","Difference");
      $_POST[$info[2]]['Weir_Height']=$info[0];
      $_POST[$info[2]]['Box_Top']=$info1[0];
      $_POST[$info[2]]['Difference']=$info1[0]-$info[0];
     }
    }
/*
    $_POST['Ox3_Chl_1']=array("Current_Value"=>2,"Num_Values"=>3,"List"=>array(0,2,4),"Hours"=>0,"Offset"=>0);
    $_POST['Ox3_Chl_2']=array("Current_Value"=>1.5,"Num_Values"=>3,"List"=>array(0,1.5,2.4),"Hours"=>0,"Offset"=>0);
    $_POST['Ox3_Chl_3']=array("Current_Value"=>4.2,"Num_Values"=>3,"List"=>array(0,4.2,5.8),"Hours"=>0,"Offset"=>0);
  */  
    
/*    fclose($f);
    fclose($g);
/*
    $f=fopen('../pondSim/params/con.top','r');$c=0;
    while($info=fscanf($f,"%f %s %s %s %s %s %s %s")){
     if (!$_POST[$routes[$c]]['Is_Pump']){
      $_POST[$routes[$c]]['Box_Top']=$info[0];
      $_POST[$routes[$c]]['Difference']=$info[0]-$_POST[$pump[$c]]['Weir_Height'];
     }
     $c++;
    }
    fclose($f);
*/

/*    $f=fopen('../pondSim/params/con.pump','r');
    $c ounter=0;$slashes=0;$c=0;
    while($info=fscanf($f,"%s\t%s\t%s\t%s\n")){
     if ($_POST[$routes[$c]]['Is_Pump']){
      $_POST[$routes[$c]]["List"]=array();
      list($first,$bla1,$bla2,$bla3)=$info;
      $counter=0;
      $slashes=0;
      while ($counter<strlen($first)){
       $tmp='';
       while($first[$counter]!='/' && $counter<strlen($first)){
        $tmp=$tmp.$first[$counter];
        $counter++;
       }
       $slashes++;
       if ($slashes==1){
        $_POST[$routes[$c]]['Current_Value']=$tmp;
       }
       else {
        $_POST[$routes[$c]]['List'][]=$tmp;
       }
       $counter++;
      }
      $_POST[$routes[$c]]['Num_Values']=$slashes-1;
     }
     $_POST[$routes[$c]]['Hours']=0;
     $_POST[$routes[$c]]['Offset']=0;
     $c++;
    }
    fclose($f);*/

    
/*

    $NAME[]='pval';
    $NAME[]='pname';
    $_POST['pval']=$pval;
    $_POST['pname']=$pval;
    $year=$_POST["I1"]["year"];
    $day=$_POST["I1"]["day"];
    
    $months=array("January","February","March","April","May","June","July","August","September","October","November","December");
    $month=$months[$_POST["I1"]["month"]-1];
    $NAME[]='month';
    $NAME[]='year';
    $NAME[]='day';
    $NAME[]='Page2Select';
    $NAME[]='P2Name';
    $NAME[]='P2id';
    $NAME[]='inflow';
    $_POST['inflow']=$ival;    
    $_POST['month']=$month;
    $_POST['year']=$year;
    $_POST['day']=$day;
    $temmp='Pond-1';
    $_POST['Page2Select']=$temmp;
    $ _POST['P2Name']="Pond 1";
    $_POST['P2id']="Pond-1";
    $NAME[]='rnam';
    $NAME[]='pnam';
    $NAME[]='P2Pic';
    srand(time());
    $rnam=''.(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).'.txt';
    $pnam=''.(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).(rand()%9).'.txt';
    $_POST['rnam']=$rnam;
    $_POST['pnam']=$pnam;
    $_POST['P2Pic']='Pond1_Green.gif';
   }
   
   if ($_POST['modelRunning']==1){
    system(" >../pondSim/inputs/test_Jordan.txt");
    $f=fopen("../pondSim/inputs/test_Jordan.txt",'w');
    foreach ($routes as $pump){
     $txt='';
     $txt=$txt.$_POST[$pump]['Weir_Height']."       #".$pumpDescriptor[$pump]."\n";
     fwrite($f,$txt);
    }
/*    $f=fopen('tmp/'.$_POST['rnam'],'w');
    foreach ($GNAM as $val){
     $string=''.$val.' '.$_POST[$val]."\n";
     fwrite($f,$string);
    }
    fclose($f);*/
   
/*    system("R --slave --vanilla <../pondSim/pondSim.R &");
//    system("R --slave --vanilla --args tmp/".$_POST['pnam']." <quick.R >tmp/useless.tst &");
   }
   if ($_POST['modelRunning']==2){
    $f=fopen('otherparam.txt','r');
    while($info=fscanf($f,"%s\t%f\n")){
     list($name,$value)=$info;
     $_POST[$name]=$value;
    }
    fclose($f);
   }*/
  ?>

  <script type="text/javascript">
/*   var pg2on="<?=$_POST['Page2Select']?>";
   var pg2menu = null;
   var timer = 0;
   var counter=0;
   var pars=0;
   var oname;
   var oid;
   
   function check(){
    if (document.myform.modelRunning.value==2) {document.myform.modelRunning.value=0;}
   }

   function spar(val){ pars=val; }

   function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
   }
   
   function chgpg2(tis){
    var el=getElementsByClass("pg2pics");
    var teist=false;
    c=0;
    while(c<el.length){
     if (el[c].id!=tis)
      document.getElementById(el[c].id).style.visibility="hidden";
     else
      teist=true;
     c++;
    }
    if (teist)
     document.getElementById(tis).style.visibility="visible";
   }
/*
   var opic="<?=$_POST['P2Pic']?>";

   function SelPage(val, name, pic){
    document.getElementById("changeable").innerHTML = name;
    oname=name;
    oid=val;
    document.getElementById(pg2on).style.visibility="hidden";
    document.getElementById(val).style.visibility="visible";
    pg2on=val;
    opic=pic;

    document.getElementById("pg2pics").innerHTML="<hr><h1 align=center><img src=\"figs/"+pic+"\" align=middle></h1> <hr>"
    
   }*/

 /*  function isNumber(nerd,one){
    ner=String(nerd)+String(one);
    var ValidMChars="0123456789";
    var i=0,nd=0;
    if (ner.charAt(i)=="-") i++;
    while (i<ner.length){
     if (ner.charAt(i)=="."){ if (nd==0){ nd=1;} else return false;}
     else if (ValidMChars.indexOf(ner.charAt(i))==-1){ return false;}
     i++;
    }
    return true;
   }

    function num(field,e,other,end){
    var key;
    var keychar;
    var is=true;

    if (window.event){key=window.event.keyCode;}
    else if (e){key=e.which;}
    keychar=String.fromCharCode(key);

    if (!isNumber(field.value, keychar)) is=false;
    if (key==null||key==0||key==8||key==9||key==13||key==27||key==37||key==39||(key==46)& keychar!=".")
     is=true;

    if (is && end){
     change(field,other,end);
    }
    
    return is;
    
   }
 
   function change(field,other,end){
     document.getElementById(other+"_Id").value=Math.round(10000*parseFloat((end-field.value)*1))/10000;
   }


   function Load(){
    <?php foreach ($NAME as $val){ 
    if (is_numeric($_POST[$val])){
     echo '    document.myform.'.$val.'.value='.$_POST[$val].';';echo"\n";}
    else{
     echo '    document.myform.'.$val.'.value="'.$_POST[$val].'";';echo "\n";}
     }?>
     <?php if($pg==2){?>
      document.myform.P2Name.value=oname;
      document.myform.P2id.value=oid;
     <?php }?>
//      document.myform.P2Pic.value=opic;
    <?php foreach ($routes as $val){
     echo '    document.myform.'.$val.'_Weir_Height.value='.$_POST[$val]['Weir_Height'].';';echo"\n";
     echo '    document.myform.'.$val.'_Box_Top.value='.$_POST[$val]['Box_Top'].';';echo"\n";
     echo '    document.myform.'.$val.'_Difference.value='.$_POST[$val]['Difference'].';';echo"\n";
     }
     foreach ($pumps as $val){
     echo '    document.myform.'.$val.'_Current_Value.value='.$_POST[$val]['Current_Value'].';';echo"\n";
     echo '    document.myform.'.$val.'_Num_Values.value='.$_POST[$val]['Num_Values'].';';echo"\n";
     echo '    document.myform.'.$val.'_Hours.value='.$_POST[$val]['Hours'].';';echo"\n";
     echo '    document.myform.'.$val.'_Offset.value='.$_POST[$val]['Offset'].';';echo"\n";
     $c=0;
      foreach ($_POST[$val]['List'] as $value){
      echo '    document.myform.'.$val.'_List_'.$c.'.value='.$value.';';echo"\n";
      $c++;
      }
     }
    }
    foreach ($ponds as $val){
     echo '    document.myform.'.$val.'.value='.$_POST[$val].';'."\n";
    }
    $c=0;

    while($c<5){
     foreach ($rerun as $val){
      echo '    document.myform.I'.$c.'_'.$val.'.value='.$_POST["I".$c][$val].';'."\n";
     }
     $c++;
    }
    ?>
    check();
   }

   function spage(i,v,p){
    if ((<?=$pg?>!=i && <?=$_POST['modelRunning']?>!=1) || v==1){
     document.myform.modelRunning.value=p;
     document.myform.pg.value=i;
     document.myform.submit();
    }
   }

   (function(){
   var menu1=new Scl.Menu(180);
    menu1.addItem('Jordan Pierce','mailto:jsp26@humboldt.edu?subject=Marsh Project');
    menu1.addItem('Cameron Bracken','mailto:cameron.bracken@humboldt.edu?subject=Marsh Project');
    menu1.addItem('Neil Berezovsky','mailto:nir.berezovsky@humboldt.edu?subject=Marsh Project');
    menu1.addItem('Amelia Dillon','mailto:amelia.robin@gmail.com?subject=Marsh Project');
    menu1.addItem('Jason Roberts','mailto:jasonroberts53@gmail.com?subject=Marsh Project');
    menu1.dockTo('contacts');
   })();

   onerror=handleError;
   function handleError(msg,url,line){
    var txt="";
    txt="An error has occured on this page.\n\n";
    txt+="Error: "+msg+'\n';
    txt+="URL: "+url+'\n';
    txt+="Line: "+line+'\n';
    alert(txt);
   }

   function imgopac(name,id,height,low,high) {
    range=(high-low);
    prc=(height-low)/range;
    prc=prc*4;
    if (prc<0) prc=0;
    if (prc>5) prc=5;
    
    back=new Array("_Blue.gif","_Teal.gif","_Green.gif","_Yellow.gif","_Red.gif");
    set=Math.floor(prc);
    alp=prc-set;

    if (set<0) set=0;
    if (set>4) set=4;
    if (alp<0) alp=0;
    if (alp>1) alp=1;

    document.write('<img src="'+ name + back[set] +'" id="'+id+'">');
    document.write('<img style="-moz-opacity:'+alp+';filter:alpha(opacity='+100*alp+');" src="'+name+back[set+1]+'" id="'+id+'">');
   }
  
    jdatafile="tmp/hello.txt";

  function reload(){
   spage(1,1,2);
  }
 


  </script>

 </head>
 <body onLoad="Load();">
  <form name="myform" action="marsh.php" method="post"> 


<?php 
/*
 $f=fopen('modelStatus','r');
 $info=fscanf($f,"%f\n");
 $status=$info[0];
 fclose($f);
 if ($_POST && !$statuas && $_POST['modelRunning']!=1){*/
?>



   <div id="head">

    <table id="topHeader" cellpadding="0" cellspacing="0" border="0" height="100px" style="background-color:#3c7ea9;">
     <tr><td valign="top" width="150px" height="100px">
		<img src="figs/hand.png" height="70px" style="padding:30px 0px 0px 10px;"/>
      </td><td valign="top" width="100%" height="30px">
      <div id="header"> 
       &nbsp;&nbsp;Arcata Marsh Project
      </div>
     </td>
	</tr>
    </table>

    <table id="sideHeader" cellspacing="0" cellpadding="0" border="0" height="1100px" width="150px" style="background-color:#3c7ea9;">
     <tr width="150px"><td valign="top">
       <div id="lcol">

       

<br/>

        <input type="hidden" name="pg" >
<?php/* foreach ($NAME as $var ){*/ ?>
<!--        <input type="hidden" name="<?=$var?>">
<?php/* }*/?>
        <input type="hidden" name="modelRunning">
<?php/* foreach ($routes as $val){
         echo '        <input type="hidden" name="'.$val.'_Is_Pump">';echo"\n";
         if (!$_POST[$val]['Is_Pump']){
         echo '        <input type="hidden" name="'.$val.'_Weir_Height">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Is_Adjustable">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Box_Top">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Difference">';echo"\n";
         }else{
         echo '        <input type="hidden" name="'.$val.'_Current_Value">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Num_Values">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Hours">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Offset">';echo"\n";
         $c=0;
foreach ($_POST[$val]['List'] as $value){
         echo '        <input type="hidden" name="'.$val.'_List_'.$c.'">';echo"\n";
         $c++;
         }
         }
        }
        foreach ($ponds as $val){
         echo '        <input type="hidden" name="'.$val.'">'."\n";
        }
        $c=0;
        while($c<5){
         foreach ($rerun as $val){
          echo '        <input type="hidden" name="I'.$c.'_'.$val.'">'."\n";
         }
         $c++;
        }*/
        ?>
-->
        <div id="test" onclick="spage(1,0,0);" <?php if($pg==1) echo'style="background-color:#AFC7C7"';?>>&nbsp;
         Forecast 
        </div>

        <div id="test" onclick="spage(2,0,0);" <?php if($pg==2) echo'style="background-color:#AFC7C7"';?>>&nbsp;
         Inputs
        </div>

        <div id="test" onclick="spage(3,0,0);" <?php if($pg==3) echo'style="background-color:#AFC7C7"';?>>&nbsp;
         Parameters
        </div>

        <div id="test" onclick="spage(4,0,0);" <?php if($pg==4) echo'style="background-color:#AFC7C7"';?>>&nbsp; 
         Rating Curves
        </div>

        <div id="test" onclick="spage(5,0,0);" <?php if($pg==5) echo'style="background-color:#AFC7C7"';?>>&nbsp; 
         Model Info
        </div>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<br/>
		<div id="Contacts">
		&nbsp;<span id="contacts" style="cursor:pointer"> Contacts <img src="figs/ltl.gif"></span>
		</div>

       </div>
		

       <div id="info">
        This site was created by the Humboldt State University Capstone Design Team, 2008.
		<img src="figs/HSUStackedLogo.gif" width="130px" style="padding:5px;"/>
		
       </div>

     </td></tr>
    </table>
    <div id="MBody">

    <!--
    Main Body Starts Here
    -->



     <?php/* switch ($pg){case 1:*/?> <!-- Put data for page 1 here -->
<!-- ######################################################
###########################################################
#
#
#                   PAGE 1
#
#
###########################################################
########################################################### -->
     <div class="PageDiv" id="pg1bdy">
     <table id="inf"><thead><tr><th>Date</th><th>Precip</th><th>Inflow</th></tr></thead>
     <caption>Predicted Precipitation and Inflow</caption>
      <?php /*
      $c=0;
      while ($c<5){
       if($c!=1){
        echo'<tr><td>'.$months[$_POST["I".$c]["month"]-1].' '.$_POST["I".$c]["day"].'</td><td>'.$_POST["I".$c]["precip"].'</td><td>'.$_POST["I".$c]["inflow"].'</td></tr>'."\n";
       }
       else{
        echo'<tr style="background-color:snow;"><td>'.$months[$_POST["I".$c]["month"]-1].' '.$_POST["I".$c]["day"].'</td><td>'.$_POST["I".$c]["precip"].'</td><td>'.$_POST["I".$c]["inflow"].'</td></tr>'."\n";
       }
       $c++;
      }*/
     ?>
     </table>
<!--     <div id="banner">
      <h1 id="date"><?/*=$_POST['month']?> <?=$_POST['day']*/?>, <?/*=$_POST['year']*/?>
       <input type="button" value="Run Model" onclick="spage(1,1,1);car=0;">
       </h1> 
       &nbsp;&nbsp;Expected Precipitation: <?php/* echo $_POST['pval'];" inches";*/?>
       &nbsp;&nbsp;Expected Inflow: <?php/* echo $_POST['inflow'];" MGD";*/?>
     </div>-->

     <img src="figs/ratingC.jpg" id="pg1bar">


<!--     <img src="figs/Marshes_Blue.gif" name="Marshes" id="MRSH" style="filter:alpha(opacity=60)" >
     <br />-->

     <div id="PictureWrapper">

     <script type="text/javascript">
      imgopac("figs/Pond1","P1",<?=$_POST['Ox1']?>,5,6);
      imgopac("figs/Pond2","P2",<?=$_POST['Ox2']?>,5,6);
      imgopac("figs/Pond3","P3",<?=$_POST['Ox3']?>,5,6);
      imgopac("figs/TM1","TM1",<?=$_POST['TM1']?>,2,4);
      imgopac("figs/TM2","TM2",<?=$_POST['TM2']?>,2,4);
      imgopac("figs/TM3","TM3",<?=$_POST['TM3']?>,2,4);
      imgopac("figs/TM4","TM4",<?=$_POST['TM4']?>,2,4);
     </script>

     </div>

     <div id="pg1info">
      Forcast data are based off National Weather Service <a href="http://www.wrh.noaa.gov/forecast/wxtables/index.php">Quantitative Precipitation Forecasts</a> (QPF).
       
     </div>

     </div>


     <script type="text/javascript">
      if (<?/*=$_POST['modelRunning']*/?>==1){
       var childWindow;
       windowOptions=('status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=No,scrollbars=0,height=50,width=150');
       childWindow=window.open('dancing.php','Loading',windowOptions);
       childWindow.moveTo(screen.width/2,screen.height/2);
      }
      
     </script>


     <?php/* break;case 2:*/ ?> <!-- Put data for page 2 here -->
<!-- ######################################################
###########################################################
#
#
#                   PAGE 2
#
#
###########################################################
########################################################### -->

     <div class="PageDiv" id="pg2bdy">

     <h1><u>Flow Rates</u></h1><br />
     <table><tr><td width="275px">
     Total Plant Inflow:</td><td>    
     <input class="textfield" type="text" name="TPI" onkeypress="return num(this,event);" id="TPI_ID" /><br />
     <br /></td></tr><tr><td>

     Pond 2 Storm Pump:</td><td> 
     <input class="textfield" type="text" name="P2SP" onkeyup="summe();" onkeypress="return num(this,event);" id="P2SP_ID" /><br /></td></tr><tr><td>

     Plant Effluent:</td><td>
     <input class="textfield" type="text" name="PE" onkeyup="summe();" onkeypress="return num(this,event);" id="PE_ID" /><br /></td></tr><tr><td>
    
     Wetland Effluent:</td><td>
     <input class="textfield" type="text" name="WE" onkeyup="summe();" onkeypress="return num(this,event);" id="WE_ID" /><br /></td></tr><tr><td>
     
     Total Input to Contact Basin =</td><td> 

     <input class="textfield" type="text" name="CB" readonly id="CB_ID" />

     </td> </tr></table>
     <br />

     <table><tr><td width="275px">
     Wetland Influent:</td><td>  
     <input class="textfield" type="text" name="WI" onkeyup="summer();" onkeypress="return num(this,event);" id="WI_ID" /><br /></td></tr><tr><td>

     Bay Discharge =</td><td> 
     <input class="textfield" type="text" name="BD" readonly id="BD_ID"/>
     <br />

     </td></tr></table>

     <div id="pg2info">
      <b><u>To Run Model</u></b><br />
      Update all parameters with daily data.  If any weir heights or 
      pump flow rates have changed, go to 'Parameters' page and 
      to update those parameters.  
      Once all fields have been updated, click the 'Run Model' button.  
      While the model is running do not close any popup windows or press the 
      Back button.  After several minutes the web page will refresh with the 
      model results.

     </div>
     <input type="button" value="Run Model" onclick="spage(1,1,1);car=0;" id="pg2button">

     <hr>
    

     <br /><br />
     <h1><u>Water Surface Elevation</u></h1><br />   

     <table><tr><td>

     <table> <tr><td width="275px">

     Pond #1</td><td>
     <input class="textfield" name="P1" onkeypress="return num(this,event);" id="P1_ID" onfocus="changeDescription(0);" value="<?=round($_POST["Ox1"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'"/><br /></td></tr><tr><td>
     Pond #2</td><td>
     <input class="textfield" name="P2" onkeypress="return num(this,event);" id="P2_ID" onfocus="changeDescription(1);" value="<?=round($_POST["Ox2"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
     Pond #3</td><td>
     <input class="textfield" name="P3" onkeypress="return num(this,event);" id="P3_ID" onfocus="changeDescription(2);" value="<?=round($_POST["Ox3"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
     Marsh #1</td><td>
     <input class="textfield" name="M1" onkeypress="return num(this,event);" id="M1_ID" onfocus="changeDescription(3);" value="<?=round($_POST["TM1"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
     Marsh #2</td><td>
     <input class="textfield" name="M2" onkeypress="return num(this,event);" id="M2_ID" onfocus="changeDescription(4);" value="<?=round($_POST["TM2"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
     Marsh #3</td><td>
     <input class="textfield" name="M3" onkeypress="return num(this,event);" id="M3_ID" onfocus="changeDescription(5);" value="<?=round($_POST["TM3"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
     Enhancement</td><td>
     <input class="textfield" name="E" onkeypress="return num(this,event);" id="E_ID" onfocus="changeDescription(6);" value="<?=round($_POST["ALLEN"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>

     </td></tr></table></td><td width="75in">
     </td><td>

     <textarea id="Description" rows="5" cols="50" name="Descriptio" readonly>Hello Jordan</textarea>

     </td></tr></table>

     <script type="text/javascript">

     function summe(){
      try{
      var pump=eval("document.myform.P2SP_ID");
      var we=eval("document.myform.WE_ID");
      var pe=eval("document.myform.PE_ID");
      var cb=eval("document.myform.CB_ID");

      pumpval= (pump.value == "" || pump.value == ".") ?  0 : pump.value;
      weval  = (  we.value == "" ||   we.value == ".") ? 0 : we.value;
      peval  = (  pe.value == "" ||   pe.value == ".") ? 0 : pe.value;

      cb.value= Math.round(1000*(parseFloat(pumpval)+parseFloat(weval)+parseFloat(peval)))/1000;
      summer();
      }
      catch (err){alert(err);}
     }


     function summer(){
      try{
       var bayDischarge=eval("document.myform.BD_ID");
       var wetlandInfluent=eval("document.myform.WI_ID");
       var cb=eval("document.myform.CB_ID");
       wet=wetlandInfluent.value == "" ? 0 : wetlandInfluent.value;
       wet=wet == "." ? 0 : parseFloat(wet);
       cbv=cb.value == "" ? 0 : cb.value;
       bayDischarge.value=Math.round(1000*(parseFloat(cbv)-parseFloat(wet)))/1000;
      }catch(err){alert(err);}
     }

     function changeDescription(a){
      try{
      var desc=[7];
      desc[0]=" Pond #1 surface elevation measurement directions: \n   -staff guage measurement on North weir box \n    box (closest to treatment plant)";
      desc[1]=" Pond #2 surface elevation measurement directions: \n   -staff guage measurement on \n    West marsh #2 weir box";
      desc[2]=" Pond #3 surface elevation measurement directions: \n   -water height from outlet box top";
      desc[3]="Marsh #1 surface elevation measurement directions: \n   -water height above NW corner box in inches";
      desc[4]="Marsh #2 surface elevation measurement directions: \n   -staff guage measurement on \n    weir box (closest to Marsh #1)";
      desc[5]="Marsh #3 surface elevation measurement directions: \n   -staff guage measurement on North \n    weir box (closest to treatment plant)";
      desc[6]="Gearheart surface elevation measurement directions: \n   -staff guage measurement on \n    South West weir box";
       document.getElementById("Description").value=desc[a];
      }
      catch(err){
       alert(err);
      }
     }

    
     </script>

     <hr>     
    
     

     <br /><br />
     <h1><u>Weir Elevations</u></h1><br />

     <table><tr><td width="275px">

     Pond #2 East Outlet to Marsh #1:</td><td>
     <input class="textfield" type="text" name="P2EOM1" onkeypress="return num(this,event);" id="P2EOM1_ID" /><br /></td></tr><tr><td>
     Pond #2 West Outlet to Marsh #1:</td><td>
     <input class="textfield" type="text" name="P2WOM2" onkeypress="return num(this,event);" id="P2WOM1_ID" /><br /></td></tr><tr><td>
     Pond #2 East Outlet to Marsh #2:</td><td>
     <input class="textfield" type="text" name="P2EOM2" onkeypress="return num(this,event);" id="P2EOM2_ID" /><br /></td></tr><tr><td>
     Pond #2 West Outlet to Marsh #2:</td><td>
     <input class="textfield" type="text" name="P2WOM2" onkeypress="return num(this,event);" id="P2WOM2_ID" /><br /></td></tr><tr><td>
 
     </td></tr></table><hr>

     </div>
  

     <?php/* break;case 3:*/?> <!-- Put data for page 3 here -->

<!-- ######################################################
###########################################################
#
#
#                   PAGE 3
#
#
###########################################################
########################################################### -->

      <div id="pg2pics">
       <img src="figs/marshes_green.gif"/>
       <img src="figs/Ox2_TM2_Weir_2.gif"   id="Ox2_TM1_1"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox2_TM2_Weir_2.gif"   id="Ox2_TM1_2"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox2_TM2_Weir_2.gif"   id="Ox2_TM2_1"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox2_TM2_Weir_2.gif"   id="Ox2_TM2_2"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox3_TM3_Weir.gif"     id="Ox3_TM3"    class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox2_Ox2Box.gif"       id="Ox2_Ox2Box" class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/TBox_Chl.gif"         id="TBox_Chl"   class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Hauser_Chl.gif"       id="Hauser_Chl" class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Chl_Allen.gif"        id="Chl_Allen"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox3_Chl_1.gif"        id="Ox3_Chl_1"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox3_Chl_2.gif"        id="Ox3_Chl_2"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Ox2_Chl.gif"          id="Ox3_Chl_3"  class="pg2pics" style="visibility:hidden;"/>
       <img src="figs/Chl_Bay.gif"          id="Chl_Bay"    class="pg2pics" style="visibility:hidden;"/>
      </div>
    
      <div class="PageDiv" id="pg2p">
      <h1><u>Flow Rates</u></h1><br />
      <table><tr><td width="275px">
      Total Plant Inflow:</td><td>    
      <input class="textfield" type="text" name="TPI" onkeypress="return num(this,event);" id="TPI_ID" /><br />
      <br /></td></tr><tr><td>

      Pond 2 Storm Pump:</td><td> 
      <input class="textfield" type="text" name="P2SP" onkeyup="summe();" onkeypress="return num(this,event);" id="P2SP_ID" /><br /></td></tr><tr><td>

      Plant Effluent:</td><td>
      <input class="textfield" type="text" name="PE" onkeyup="summe();" onkeypress="return num(this,event);" id="PE_ID" /><br /></td></tr><tr><td>
     
      Wetland Effluent:</td><td>
      <input class="textfield" type="text" name="WE" onkeyup="summe();" onkeypress="return num(this,event);" id="WE_ID" /><br /></td></tr><tr><td>
      
      Total Input to Contact Basin =</td><td> 

      <input class="textfield" type="text" name="CB" readonly id="CB_ID" />

      </td> </tr></table>
      <br />

      <table><tr><td width="275px">
      Wetland Influent:</td><td>  
      <input class="textfield" type="text" name="WI" onkeyup="summer();" onkeypress="return num(this,event);" id="WI_ID" /><br /></td></tr><tr><td>

      Bay Discharge =</td><td> 
      <input class="textfield" type="text" name="BD" readonly id="BD_ID"/>
      <br />

      </td></tr></table>

      <input type="button" value="Run Model" onclick="spage(1,1,1);car=0;" id="pg2button">

      <hr>
      <h1>Weirs </h1><p> Weir heights are measured in feet from the top of the weir box</p> <br />
      <?php/* $_POST['Chl_Bay']['Is_Adjustable']=false;*/ ?>
      <table id="pg2table" rules="groups"><thead><tr style="font-size:small;border-bottom:1px;"><th>Description</th><th>From Top</th><th>Absolute Elevation</th></tr></thead>
      <?php/* foreach ($routes as $pump){
       if (!$_POST[$pump]['Is_Pump'] && $_POST[$pump]['Is_Adjustable']){
       echo "<tr><td width=\"300px\">$pumpDescriptor[$pump]: </td><td width=\"100px\">\n";
       echo '
        <input class="textfield" 
        type="text" 
        name="'.$pump.'_Weir_Height" 
        id="'.$pump.'_Weir_Height_Id" 
        value="'.$_POST[$pump]['Weir_Height'].'" 
        onkeypress="return num(this,event);" 
        onfocus="chgpg2(\''.$pump.'\');" onkeyup="change(this,\''.$pump.'_Difference\','.$_POST[$pump]['Box_Top'].');"/> 
       </td><td> 
       <input class="textfield" 
        type="text" name="'.$pump.'_Difference" 
        id="'.$pump.'_Difference_Id" 
        onkeypress="return num(this,event);" 
        value="'.($_POST[$pump]['Box_Top']-$_POST[$pump]['Weir_Height']).'" onkeyup="change(this,\''.$pump.'_Weir_Height\','.$_POST[$pump]['Box_Top'].');
        " onfocus="chgpg2(\''.$pump.'\');"/> 
       </td></tr>'."\n";
       
       }
      }*/ ?>
      </table>
      <hr>
      <h1>Pumps</h1><p> Pumping capacities are measured in MGD  </p> <br />


      <table id="pg2table" rules="groups">
      <thead><tr style="font-size:small;border-bottom:1px;"><th>Description</th><th>Pump Rate</th><th>Pump Hours</th><th>Offset Hours</th></thead>
<?php/* foreach ($pumps as $pump){
        echo "      <tr><td width=\"300px\">$pumpDescriptor[$pump]: </td><td>\n";
        echo '      <select id="pg2s" type="select" onChange="document.myform.'.$pump.'_Current_Value.value=this.selectedIndex+1" onfocus="chgpg2(\''.$pump.'\')">'."\n";
        $c=0;$aqs=" ";
         foreach ($_POST[$pump]['List'] as $value){
          if ($c+1==$_POST[$pump]['Current_Value']){ $aqs=' selected ';}
          else{ $aqs=' ';}
//          echo $aqs;
          echo '      <option value='.$value.' '.$aqs.'>'.$value."\n";
          $c++;
         }
        echo '      </select></td><td>'."\n";
        echo '      <input class="textfield" style="width:50px;" name="'.$pump.'_Hours'.'" onfocus="chgpg2(\''.$pump.'\')" value="'.$_POST[$pump]['Hours'].'" >'."\n";
        echo '      </td><td><input class="textfield" style="width:50px" name="'.$pump.'_Offset'.'" onfocus="chgpg2(\''.$pump.'\')" value="'.$_POST[$pump]['Offset'].'"></td></tr>'."\n\n\n";
        
      }*/
      ?>
      </table><br /><hr>

      <h1><u>Water Surface Elevations</u></h1><br />   

      <table><tr><td>

      <table> <tr><td width="275px">

      Pond #1</td><td>
      <input class="textfield" name="P1" onkeypress="return num(this,event);" id="P1_ID" onfocus="changeDescription(0);" value="<?=round($_POST["Ox1"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'"/><br /></td></tr><tr><td>
      Pond #2</td><td>
      <input class="textfield" name="P2" onkeypress="return num(this,event);" id="P2_ID" onfocus="changeDescription(1);" value="<?=round($_POST["Ox2"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
      Pond #3</td><td>
      <input class="textfield" name="P3" onkeypress="return num(this,event);" id="P3_ID" onfocus="changeDescription(2);" value="<?=round($_POST["Ox3"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
      Marsh #1</td><td>
      <input class="textfield" name="M1" onkeypress="return num(this,event);" id="M1_ID" onfocus="changeDescription(3);" value="<?=round($_POST["TM1"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
      Marsh #2</td><td>
      <input class="textfield" name="M2" onkeypress="return num(this,event);" id="M2_ID" onfocus="changeDescription(4);" value="<?=round($_POST["TM2"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
      Marsh #3</td><td>
      <input class="textfield" name="M3" onkeypress="return num(this,event);" id="M3_ID" onfocus="changeDescription(5);" value="<?=round($_POST["TM3"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>
      Enhancement</td><td>
      <input class="textfield" name="E" onkeypress="return num(this,event);" id="E_ID" onfocus="changeDescription(6);" value="<?=round($_POST["ALLEN"],3)?>" style="color:#777;" onkeyup="this.carriage=1;this.style.color='#000'" /><br /></td></tr><tr><td>

      </td></tr></table></td><td width="75in">
      </td></tr></table>

      <textarea id="Description" rows="5" cols="50" name="Descriptio" readonly>Hello Jordan</textarea>

      <script type="text/javascript">

      function summe(){
       try{
       var pump=eval("document.myform.P2SP_ID");
       var we=eval("document.myform.WE_ID");
       var pe=eval("document.myform.PE_ID");
       var cb=eval("document.myform.CB_ID");

       pumpval= (pump.value == "" || pump.value == ".") ?  0 : pump.value;
       weval  = (  we.value == "" ||   we.value == ".") ? 0 : we.value;
       peval  = (  pe.value == "" ||   pe.value == ".") ? 0 : pe.value;

       cb.value= Math.round(1000*(parseFloat(pumpval)+parseFloat(weval)+parseFloat(peval)))/1000;
       summer();
       }
       catch (err){alert(err);}
      }


      function summer(){
       try{
        var bayDischarge=eval("document.myform.BD_ID");
        var wetlandInfluent=eval("document.myform.WI_ID");
        var cb=eval("document.myform.CB_ID");
        wet=wetlandInfluent.value == "" ? 0 : wetlandInfluent.value;
        wet=wet == "." ? 0 : parseFloat(wet);
        cbv=cb.value == "" ? 0 : cb.value;
        bayDischarge.value=Math.round(1000*(parseFloat(cbv)-parseFloat(wet)))/1000;
       }catch(err){alert(err);}
      }

      function changeDescription(a){
       try{
       var desc=[7];
       desc[0]=" Pond #1 surface elevation measurement directions: \n   -staff guage measurement on North weir box \n    box (closest to treatment plant)";
       desc[1]=" Pond #2 surface elevation measurement directions: \n   -staff guage measurement on \n    West marsh #2 weir box";
       desc[2]=" Pond #3 surface elevation measurement directions: \n   -water height from outlet box top";
       desc[3]="Marsh #1 surface elevation measurement directions: \n   -water height above NW corner box in inches";
       desc[4]="Marsh #2 surface elevation measurement directions: \n   -staff guage measurement on \n    weir box (closest to Marsh #1)";
       desc[5]="Marsh #3 surface elevation measurement directions: \n   -staff guage measurement on North \n    weir box (closest to treatment plant)";
       desc[6]="Gearheart surface elevation measurement directions: \n   -staff guage measurement on \n    South West weir box";
        document.getElementById("Description").value=desc[a];
       }
       catch(err){
        alert(err);
       }
      }

     
      </script>
      </div>
  
     <?php/* break;case 4:*/?> <!-- Put data for page 4 here -->
<!-- ######################################################
###########################################################
#
#
#                   PAGE 4
#
#
###########################################################
########################################################### -->
     <table id="pg4table" rules="groups"><thead><tr style="font-size:small;border-bottom:1px;"><th>Pond</th><th>Head</th><th>W-TM1</th><th>W-TM2</th><th>Q-TM1</th><th>Q-TM2</th><th>Q Total</th></tr></thead>
     <tr><td>Ox2: 
     </td><td>
     <input class="textfield" name="Ox2_Head" id="Ox2_Head_Id" value="6.0" onkeypress="return num(this,event);" onkeyup="popu();"></td><td> 
     <input class="textfield" name="Ox2_TM1" id="Ox2_TM1_Id" value="<?=$_POST['Ox2_TM1_1']['Weir_Height']?>" onkeypress="return num(this,event);" onkeyup="popu();"></td><td> 
     <input class="textfield" name="Ox2_TM2" id="Ox2_TM2_Id" value="<?=$_POST['Ox2_TM2_1']['Weir_Height']?>" onkeypress="return num(this,event);" onkeyup="popu();"></td><td> 
     <input class="textfield" name="Ox2_QTM1" id="Ox2_QTM1_Id" onkeypress="return num(this,event);" onkeyup="popu();"></td><td> 
     <input class="textfield" name="Ox2_QTM2" id="Ox2_QTM2_Id" onkeypress="return num(this,event);"></td><td> 
     <input class="textfield" name="Ox2_Qtot" id="Ox2_Qtot_Id" onkeypress="return false">
     </td></tr>
     <tr><td>
     </td><td>
     <input type="checkbox" name="Ox2_Head_Bullet" onclick="checkbox(this,'Ox2_Head_Id');">
     </td><td>
     <input type="checkbox" name="Ox2_TM1_Bullet" onclick="checkbox(this,'Ox2_TM1_Id');">
     </td><td>
     <input type="checkbox" name="Ox2_TM2_Bullet" onclick="checkbox(this,'Ox2_TM2_Id');">
     </td><td>
     <input type="checkbox" name="Ox2_QTM1_Bullet" onclick="checkbox(this,'Ox2_QTM1_Id');">
     </td><td>
     <input type="checkbox" name="Ox2_QTM2_Bullet" onclick="checkbox(this,'Ox2_QTM2_Id');">
     </td><td>
     <input type="checkbox" name="Ox2_Qtot_Bullet">
     </td></tr>
     </table>
     
     <script type="text/javascript">
      function checkbox(element,id){
       if (element.checked) 
        document.getElementById(id).className='noedit';
       else
        document.getElementById(id).className='textfield';

       document.getElementById(id).readOnly=element.checked;
      }
      function popu(){
       document.getElementById("Ox2_QTM1_Id").value=Math.round(1000*Math.pow(parseFloat(document.getElementById("Ox2_Head_Id").value)-parseFloat(document.getElementById("Ox2_TM1_Id").value),2.71828183))/1000;
       document.getElementById("Ox2_QTM2_Id").value=Math.round(1000*Math.pow(parseFloat(document.getElementById("Ox2_Head_Id").value)-parseFloat(document.getElementById("Ox2_TM2_Id").value),2.71828183))/1000;
       document.getElementById("Ox2_Qtot_Id").value=Math.round(1000*(parseFloat(document.getElementById("Ox2_QTM1_Id").value)+parseFloat(document.getElementById("Ox2_QTM2_Id").value)))/1000;
      }
      popu();
     </script>

     <p>Rating Curves for the wooden plank weirs such as those used in TM 1 are as follows
     </p>
     <img src="figs/ratingCurve.jpg">
     <p>Rating Curves for the adjustable weirs used on Pond 2 are
     </p>
     <img src="figs/ratingCurve.jpg">
      

     <?php/* break;case 5:*/?> <!-- Put data for page 5 here -->
<!-- ######################################################
###########################################################
#
#
#                   PAGE 5
#
#
###########################################################
########################################################### -->

     This page will give information about the model: <br />
     <ul class="lst">
      <li><a href="#"> Who created it.</a>
      <li> Why it was created.
      <li> How it works (briefly).
     </ul>

     <?php break;} ?>

    </div>
   </form>
  </div>
 </body>
</html>







<?php/* }else{*/

?>

        <input type="hidden" name="pg" >
<?php/* foreach ($NAME as $var ){*/ ?>
        <input type="hidden" name="<?=$var?>">
<?php /*}*/?>
        <input type="hidden" name="modelRunning">
<?php/* foreach ($routes as $val){
         echo '        <input type="hidden" name="'.$val.'_Is_Pump">';echo"\n";
         if (!$_POST[$val]['Is_Pump']){
         echo '        <input type="hidden" name="'.$val.'_Weir_Height">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Is_Adjustable">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Box_Top">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Difference">';echo"\n";
         }else{
         echo '        <input type="hidden" name="'.$val.'_Current_Value">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Num_Values">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Hours">';echo"\n";
         echo '        <input type="hidden" name="'.$val.'_Offset">';echo"\n";
         $c=0;
foreach ($_POST[$val]['List'] as $value){
         echo '        <input type="hidden" name="'.$val.'_List_'.$c.'">';echo"\n";
         $c++;
         }
         }
        }
        foreach ($ponds as $val){
         echo '        <input type="hidden" name="'.$val.'">'."\n";
        }
        $c=0;
        while($c<5){
         foreach ($rerun as $val){
          echo '        <input type="hidden" name="I'.$c.'_'.$val.'">'."\n";
         }
         $c++;
        }*/
        ?>

        <script type="text/javascript">
            var winW = 630, winH = 460;

            if (parseInt(navigator.appVersion)>3) {
             if (navigator.appName=="Netscape") {
              winW = window.innerWidth;
              winH = window.innerHeight;
             }
             if (navigator.appName.indexOf("Microsoft")!=-1) {
              winW = document.body.offsetWidth;
              winH = document.body.offsetHeight;
             }
            }
            
//            document.write(
//             "Window width = "+winW+"<br>"
//            +"Window height = "+winH
//            )


            var car='<img src="figs/dancing.gif">';
            document.write('<table style="position:absolute;left:'+(Math.round(winW/2)-31)+';top:'+(Math.round(winH/2)-40)+'";');
            document.write(car);
            window.setTimeout('refresh()',6400);
            function refresh(){
                if (<?=$status?>==0){
                    spage(1,1,1);
                }
                else{
                    spage(1,1,2);
                }
            }
        </script>
        <br />
    </div>
    <div>
        Model in Progress...
    <div>
</body>
</html>
<?php/*
}*/
?>
